#pragma once

#include "ErrorModel.hpp"




/**
 * The CssHighlighter applies syntax highlighting to a css document.
 * Even more, it can highlight errors, by plugging in an ErrorModel.
 */
class CssHighlighter : public QSyntaxHighlighter
{
public:

	struct HighlightingRule
	{
		QRegExp           pattern;
		QTextCharFormat   format;
	};

private:

	ErrorModel*                 m_errorModel;

	QFont                       m_font;

	QVector<HighlightingRule>   m_highlightingRules;

	QRegExp                     m_commentStartExpression;
	QRegExp                     m_commentEndExpression;

	QTextCharFormat             m_normalFormat;
	QTextCharFormat             m_attributeFormat;
	QTextCharFormat             m_classFormat;
	QTextCharFormat             m_stateFormat;

	QTextCharFormat             m_singleLineCommentFormat;
	QTextCharFormat             m_multiLineCommentFormat;
	QTextCharFormat             m_quotationFormat;

public:

	CssHighlighter(QTextDocument *document = 0);



	/**
	 * Set the error model that is used to highlight errors.
	 * The syntax highlighter does not take ownership of the model.
	 */
	void setErrorModel(ErrorModel* errorModel);

	void highlightBlock(const QString &text);


	/**
	 * This is the font that is used for the entire document.
	 */
	QFont font() const;
};
///////////////////////////////////////////////////////////////////////////////////////////////////
